package modelo;

import java.util.ArrayList;

public class CaminoMinimo {
	private ArrayList<Usuario> camino;
	
	public CaminoMinimo(){
		this.camino = new ArrayList<Usuario>();
	}
	
	public void agregarElemento(Usuario user){
		if (!this.camino.contains(user)){
			this.camino.add(user);
		}
	}
	
	public boolean contains(Usuario user){
		if (this.camino.contains(user)) return true;
		return false;
	}
	
	public boolean equals(Object camino){
		CaminoMinimo unCamino = (CaminoMinimo)camino;
		for (Usuario user : this.camino){
			if (!unCamino.contains(user)) return false; 
		}
		if (this.size() != unCamino.size()) return false;
		return true;		
	}
	
	public int size(){
		return this.camino.size();
	}
	
	public CaminoMinimo copiarCamino(){
		CaminoMinimo unCamino = new CaminoMinimo();
		for (Usuario user : this.camino){
			unCamino.agregarElemento(user);
		}
		return unCamino;
	}

	public void eliminarUltimo() {
		if (!this.camino.isEmpty()){
			int ultimo = this.camino.size()-1;
			this.camino.remove(ultimo);
		}
	}

	public Usuario getUltimo() {
		return this.camino.get(this.camino.size()-1);
	}

	public Usuario get(int i) {
		return this.camino.get(i);
	}
	
	public String toString(){
		return this.camino.toString();
	}

}
